﻿using ClassLibrary;
using System;

namespace ConsoleDemo
{
    // IComparer 接口
    internal class IComparerDemo
    {
        public static void ArraySort()
        {
            int[] myInt = new[] { 20, 4, 16, 9, 2 };
            Array.Sort(myInt);
            foreach (var i in myInt)
                Console.WriteLine(i);

            SimpleClass[] mc = new SimpleClass[5];
            mc[0] = new SimpleClass() { TheValue = 20 };
            mc[1] = new SimpleClass() { TheValue = 4 };
            mc[2] = new SimpleClass() { TheValue = 16 };
            mc[3] = new SimpleClass() { TheValue = 9 };
            mc[4] = new SimpleClass() { TheValue = 2 };

            Console.WriteLine("------------------------------");

            Array.Sort(mc);
            foreach (var item in mc)
            {
                Console.WriteLine(item.TheValue);
            }
        }
    }
}
